package cg.cmm.rag.config;

import dev.langchain4j.store.embedding.pgvector.PgVectorEmbeddingStore;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author: baibing
 * create time: 2025-03-21 16:33
 * description:
 */

@Configuration
public class PgVectorConfig{
    private final PgVectorProperties pgVectorProperties;

    public PgVectorConfig(PgVectorProperties pgVectorProperties) {
        this.pgVectorProperties = pgVectorProperties;
    }
    @Bean
    public PgVectorEmbeddingStore pgVectorEmbeddingStore() {
        return PgVectorEmbeddingStore.builder()
                .host(pgVectorProperties.getHost())
                .port(pgVectorProperties.getPort())
                .user(pgVectorProperties.getUser())
                .password(pgVectorProperties.getPassword())
                .database(pgVectorProperties.getDatabase())
                .table(pgVectorProperties.getTable())
                .dropTableFirst(true)
                .createTable(true)
                .dimension(3584)//向量维度
                .build();
    }
}
